﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="index.aspx.vb" Inherits="BookOrderingSystem.index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>

        Select the district:
        <asp:DropDownList ID="ddl_Districts" runat="server" DataSourceID="ods_District" 
            DataTextField="DistrictName" DataValueField="DistrictId" 
            AutoPostBack="True">
        </asp:DropDownList>
        <br />
        <br />
        Book store:
        <asp:DropDownList ID="ddl_Bookstore" runat="server" 
            DataSourceID="ods_Bookstore" DataTextField="BookstoreName" 
            DataValueField="BookstoreId" AutoPostBack="True">
        </asp:DropDownList>
        <br />
        <br />
        <asp:GridView ID="gv_Books" runat="server" AutoGenerateColumns="False" 
            DataSourceID="ods_Books" AllowPaging="True" AllowSorting="True" 
            CellPadding="4" DataKeyNames="BookId" ForeColor="#333333" GridLines="None" 
            PageSize="30">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:ImageField DataImageUrlField="ImageUrl" HeaderText="Cover">
                </asp:ImageField>
                <asp:BoundField DataField="BookId" HeaderText="BookId" 
                    SortExpression="BookId" InsertVisible="False" ReadOnly="True" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" 
                    SortExpression="Quantity" />
                <asp:ButtonField ButtonType="Button" CommandName="Add" Text="Add to cart" />
            </Columns>
            <EditRowStyle BackColor="#7C6F57" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#E3EAEB" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F8FAFA" />
            <SortedAscendingHeaderStyle BackColor="#246B61" />
            <SortedDescendingCellStyle BackColor="#D4DFE1" />
            <SortedDescendingHeaderStyle BackColor="#15524A" />
        </asp:GridView>

    </div>
    <div>

        <asp:ObjectDataSource ID="ods_District" runat="server" DeleteMethod="Delete" 
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetData" 
            TypeName="BookOrderingSystem.BOSDataSetTableAdapters.HK_DistrictsTableAdapter" 
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="Original_DistrictId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="DistrictId" Type="Int32" />
                <asp:Parameter Name="DistrictName" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="DistrictName" Type="String" />
                <asp:Parameter Name="Original_DistrictId" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="ods_Bookstore" runat="server" DeleteMethod="Delete" 
            InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetDataByDistrictId" 
            TypeName="BookOrderingSystem.BOSDataSetTableAdapters.BookstoresTableAdapter" 
            UpdateMethod="Update">
            <DeleteParameters>
                <asp:Parameter Name="Original_BookstoreId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="BookstoreName" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="DistrictId" Type="Int32" />
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="ddl_Districts" Name="DistricId" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="BookstoreName" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="DistrictId" Type="Int32" />
                <asp:Parameter Name="Original_BookstoreId" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
        <asp:ObjectDataSource ID="ods_Books" runat="server" 
            OldValuesParameterFormatString="original_{0}" 
            SelectMethod="GetDataByBookStoreId" 
            TypeName="BookOrderingSystem.BOSDataSetTableAdapters.BS_booksTableAdapter">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddl_Bookstore" Name="BookStoreId" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>

    </div>
</asp:Content>
